package com.example.milimili;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageButton;

import com.example.milimili.util.WebChecker;

public class NoWebEmptyActivity extends AppCompatActivity {
    private ImageButton backBtn,searchBtn;
    private EditText searchText;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_no_web_empty);
        initView();
    }

    private void initView() {
        searchText=findViewById(R.id.searchText);
        backBtn=findViewById(R.id.back);
        backBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
//                Intent intent=new Intent(NoWebEmptyActivity.this,MainActivity.class);
//                NoWebEmptyActivity.this.startActivity(intent);
                NoWebEmptyActivity.this.finish();
            }
        });
        searchBtn=findViewById(R.id.search);
        searchText=findViewById(R.id.searchText);
        searchBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if(WebChecker.isConnectIsNormal(NoWebEmptyActivity.this))
                {
                    Intent intent=new Intent(NoWebEmptyActivity.this,SearchActivity.class);
//                    Log.e("check",searchText.getText().toString());
                    intent.putExtra("keyWord",searchText.getText().toString());
                    NoWebEmptyActivity.this.startActivity(intent);
                }
                else
                {
                    Intent intent=new Intent(NoWebEmptyActivity.this,NoWebEmptyActivity.class);
                    NoWebEmptyActivity.this.startActivity(intent);
                }
            }
        });
    }
}